from bs4 import BeautifulSoup
import requests

url="http://www.ngchina.com.cn/culture/"
headers={
"User-Agent" : "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
}
response=requests.get(url=url,headers=headers)
soup=BeautifulSoup(response.text,'html.parser')
img_list=soup.find_all('ul',{"class":"img_list"})
for ul in img_list:
    imgs=ul.find_all('img')
    for img in imgs:
        img_url=img['src']
        img_name=img_url.split("/")[-1]
        try:
            img_f=requests.get(img_url,stream=True)
        except Exception as e:
            print(e)
            continue
        with open('./img/%s' % img_name,'wb') as f:
            for thunk in img_f.iter_content(chunk_size=12):
                f.write(thunk)
        print("saved %s"%img_name)
